package com.wisezone.demo0210;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;

public class RandomFileTest {
    public static void main(String[] args) {
        File file=new File("E:\\Job\\Git\\java1228\\java_base\\src\\com\\wisezone\\demo0210\\test.txt");
        RandomAccessFile raf=null;
        try {
            raf=new RandomAccessFile(file,"rw");
            raf.seek(6);

            byte[] b=new byte[512];
            raf.read(b,0,4);
            String str=new String(b,0,4);
            System.out.println(str);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }catch (IOException e){
            e.printStackTrace();
        }finally {
            try {
                raf.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
